package com.sphd.education.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sphd.education.R;
import com.sphd.education.info.KeyWordInfo;

import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by ${USER_NAME} on 2016/3/2.
 */
public class HistorySearchAdapter extends BaseAdapter {
    List<KeyWordInfo> keyWordInfoList;

    public HistorySearchAdapter(List<KeyWordInfo> keyWordInfoList) {
        this.keyWordInfoList = keyWordInfoList;
    }

    @Override
    public int getCount() {
        return keyWordInfoList.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView == null) {
            convertView = View.inflate(parent.getContext(), R.layout.layout_classify_item, null);
        viewHolder=new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder= (ViewHolder) convertView.getTag();
        }
        viewHolder.classifyOneTextview.setText(keyWordInfoList.get(position).getWord());
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.classify_one_textview)
        TextView classifyOneTextview;
        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
